package com.zhbit.dao;

import com.zhbit.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface UserMapper {


    @Select("select * from mybatis.tb_user  ")
    List<User> getUsers();

    //方法存在多个参数，所有的参数前面必须加上 @Param 注解
    @Select("select * from mybatis.tb_user where id =#{id} ")
    User getUserById(@Param("id") int id);
    //Param注解要跟上述注解的id名称对上


    @Insert("insert into mybatis.tb_user(id,username,password,gender,addr) values (#{id},#{username},#{password},#{gender},#{addr}) ")
    int addUser(User user);


    @Update("update mybatis.tb_user set id=#{id},username=#{username},password=#{password},gender=#{gender},addr=#{addr} where id=#{id}")
    int updateUser(User user);
}
